package pl.grabar.clinic.client.web.actions.doctor.visit;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;

import pl.grabar.clinic.core.dao.Dao;
import pl.grabar.clinic.core.domain.visit.Visit;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Preparable;

@Action("start")
@InterceptorRef("grabarStack")
@Results({ @Result(name = "success", location = "visit.jsp"), @Result(name = "input",  type = "redirectAction", location = "list") })
public class StartVisitAction extends ActionSupport implements Preparable {

	private static final long serialVersionUID = 5096946109710108194L;

	private static final Log LOG = LogFactory.getLog(StartVisitAction.class);
	
	@Autowired
	private Dao<Visit> visitDao;

	private String visitId;
	
	private Visit visit;
	
	@Override
	public void prepare() throws Exception {
		visit = visitDao.findById(visitId);
	}

	@Override
	public void validate() {
	}

	@Override
	public String execute() throws Exception {
		return SUCCESS;
	}
	
	/*AKCESORY*/

	public String getVisitId() {
		return visitId;
	}

	public void setVisitId(String visitId) {
		this.visitId = visitId;
	}

	public Visit getVisit() {
		return visit;
	}

	public void setVisit(Visit visit) {
		this.visit = visit;
	}

	public void setVisitDao(Dao<Visit> visitDao) {
		this.visitDao = visitDao;
	}
}
